<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
    <form id="form">
        收件人：<input name="tos" type="text"><br>
        主题：<input name="subject" type="text"><br>
        内容：<input name="content" type="text"><br>
        <input type="submit" value="提交">
    </form>
</body>
<script>
    $(function () {
        $("#form").submit(function () {
            var $formthis = $(this);
            var $submitBtn = $formthis.find('input[type="submit"]');

            var validatelist = $formthis.find('input[validate],textarea[validate]');
            for (var i = 0; i < validatelist.length; i++) {
                var $validateitem = $(validatelist[i]);
                if ($validateitem.length > 0 && !$validateitem.val()) {
                    alert($validateitem.attr("placeholder"))
                    $validateitem.focus();
                    return false;
                }
            }

            var oldBtnText = $submitBtn.text();
            $submitBtn.text("正在处理");
            $submitBtn.attr("disabled", "disabled");
            $.ajax({
                type: "POST",
                url: '/test',
                data: $formthis.serialize(),
                dataType: "json",
                success: function (data) {
                    console.log(data)

                    /*if (data.Status == 200) {
                        $submitBtn.text("处理成功，正在跳转");
                        window.location = "/index";
                    }
                    else {
                        alert(data.Message);
                        $submitBtn.text(oldBtnText);
                        $submitBtn.removeAttr("disabled");
                        ChangeCheckCode()
                    }*/
                },
                error: function (data) {
                    console.log(data)
                    alert("请求出错" + data.responseJSON.Message);
                    $submitBtn.text(oldBtnText);
                    $submitBtn.removeAttr("disabled");
                    ChangeCheckCode()
                }
            })
            return false;
        });
    });
</script>

</html>